<%@ page language="java" import="java.util.*" pageEncoding="UTF8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<div class="panel collapse" minH="160" defH="160">
	<h1>统计条件设定</h1>
	<div>
		<fieldset>
		<legend>请选择考勤类别</legend>
			<s:iterator value="attTypes" var="arg">
				<input type="checkbox" value="<s:property value="#arg.id"/>" onclick="kqClick(event)"/>
				<span>
					<s:property value="#arg.name"/>
				</span>
			</s:iterator>	
		</fieldset>
		<fieldset>
				<legend>请选择部门</legend>
				<s:iterator value="args" var="arg">
				<input type="checkbox" value="<s:property value="#arg.code"/>" onclick="depClick(event)"/>
				<span>
					<s:property value="#arg.name"/>
				</span>
			</s:iterator>	
				
				
		</fieldset>
		<fieldset>
				<legend>请选择时间段</legend>
				
				<input type="radio" name="asdf23" value="1" onclick="timeClick(event)" checked="checked"/><span>本月</span>
				<input type="radio" name="asdf23" value="2" onclick="timeClick(event)"/><span>上月</span>
				<input type="radio" name="asdf23" value="3" onclick="timeClick(event)"/><span>自定义时间段</span>
				<input type="text" class="date" id="lynn-tj-page-1-adf2323"/> 至 
				<input type="text" class="date" id="lynn-tj-page-1-fghdss23"/>
<input type="button" onclick="runtj()" value="执行统计"/>
		</fieldset>
	</div>
</div>
    
<div class="panel" defH="550">
		<h1>统计图表</h1>
	<div>
		<div id="chartContainer" style="width:100%;height:400px;"></div>
	</div>
</div>

<script type="text/javascript">
var kqTypes = [];
var deps= [];
var timeType = 1;
var kqClick = function (event){
	var srcE = event.srcElement || event.target;
	if(srcE.checked) {
		kqTypes.push(srcE.value);
	} else {
		
		kqTypes = $.grep(kqTypes,function(v,n){
			if(srcE.value == v) return false;
			else return true;
		});
	}
	
}

var depClick = function (event){
var srcE = event.srcElement || event.target;
	
	if(srcE.checked) {
		deps.push(srcE.value);
	} else {
		deps = $.grep(deps,function(v,n){
			if(srcE.value == v) return false;
			else return true;
		});
	}
}

var timeClick = function (event){
	var srcE = event.srcElement || event.target;
	timeType = srcE.value;
}

var runtj = function(){
	var st = $("#lynn-tj-page-1-adf2323").attr("value");
	var et = $("#lynn-tj-page-1-fghdss23").attr("value");

	RemoteService.tj1(Math.random()+"",deps,kqTypes,timeType,st,et,function (data) {

		$.ajax({
			url:"<%=basePath %>statistics!tj1.do?flag="+data
		}).done(function(data){
			$("#chartContainer").html(data);
		});
	});
	
}


</script>